<template>
  <div class="todo-container">
    <div class="todo-wrap">
      <div class="todo-header">
        <input type="text" placeholder="请输入你的任务名称，按回车键确认" />
      </div>

      <ul class="todo-main">
        <TodoItem v-for="(item) in items" :item-data="item" :key="item.id" />
      </ul>

      <div class="todo-footer">
        <label>
          <input type="checkbox" />
        </label>
        <span> <span>已完成0</span> / 全部2 </span>
        <button class="btn btn-danger">清除已完成任务</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive } from "vue";

import TodoItem from "./TodoItem.vue";

const items = reactive([
  { id:'item01', content: "待办事项1", completed: false },
  { id:'item02', content: "待办事项2", completed: true },
  { id:'item03', content: "待办事项1", completed: false },
  { id:'item04', content: "待办事项2", completed: true },
  { id:'item05', content: "待办事项1", completed: false },
  { id:'item06', content: "待办事项2", completed: true },
  { id:'item07', content: "待办事项1", completed: false },
  { id:'item08', content: "待办事项2", completed: true },
  { id:'item09', content: "待办事项1", completed: false },
]);
</script>

<style scoped>
.todo-container {
  width: 600px;
  margin: 0 auto;
}
.todo-container .todo-wrap {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

/*header*/
.todo-header input {
  width: 560px;
  height: 28px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 7px;
}

.todo-header input:focus {
  outline: none;
  border-color: rgba(82, 168, 236, 0.8);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
    0 0 8px rgba(82, 168, 236, 0.6);
}

/*main*/
.todo-main {
  margin-left: 0px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 0px;
}

.todo-empty {
  height: 40px;
  line-height: 40px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding-left: 5px;
  margin-top: 10px;
}

/*footer*/
.todo-footer {
  height: 40px;
  line-height: 40px;
  padding-left: 6px;
  margin-top: 5px;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
  float: left;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer span {
  float: left;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}
</style>
